package EDesign23;

// 装饰者模式
public class FDecorte {


    public interface Pancake {
        void cook();
    }

    public class BasicPancake implements Pancake {
        @Override
        public void cook() {
            System.out.println("加一勺面");
            System.out.println("加一个鸡蛋");
        }
    }

    public abstract class PancakeDecorator implements Pancake {
        protected Pancake pancake;

        public void setPancake(Pancake pancake) {
            this.pancake = pancake;
        }

        public void cook() {
            if (pancake != null) {
                pancake.cook();
            }
        }
    }

    public class AddSpicyDecorator extends PancakeDecorator {
        @Override
        public void cook() {
            super.cook();
            System.out.println("加辣酱");
        }
    }

//    public static void main(String[] args) {
//        Pancake pancake = new BasicPancake();
//        PancakeDecorator addEggPancake = new AddEggDecorator();
//        addEggPancake.setPancake(pancake);
//
//        PancakeDecorator addSaucePancake = new AddSauceDecorator();
//        addSaucePancake.setPancake(addEggPancake);
//
//        PancakeDecorator addLaTiaoPancake = new AddLaTiaoDecorator();
//        addLaTiaoPancake.setPancake(addSaucePancake);
//
//        addLaTiaoPancake.cook();
//    }


}
